package com.basic.backend.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.basic.backend.model.entity.AnalysisResult;
import com.basic.backend.model.entity.Articles;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
* @author ASUS
* @description 针对表【articles】的数据库操作Mapper
* @createDate 2025-03-03 22:07:44
* @Entity com.basic.backend.model.entity.Articles
*/
@Mapper
public interface AnalysisResultMapper extends BaseMapper<AnalysisResult> {
    @Select("SELECT * FROM analysis_results WHERE articleId = #{articleId}")
    AnalysisResult selectByArticleId(@Param("articleId") Long articleId);

    // 或使用条件构造器
    default AnalysisResult selectByArticleIdWrapper(Long articleId) {
        return selectOne(new QueryWrapper<AnalysisResult>()
                .eq("article_id", articleId)
                .last("LIMIT 1"));
    }



    // 根据 articleId 更新（非主键）
    int updateByArticleId(AnalysisResult result);

    // 插入方法
    int insert(AnalysisResult result);

    @Select("SELECT COUNT(*) FROM analysis_results WHERE articleId = #{articleId}")
    Long countByCondition(String s);
}




